﻿@model IEnumerable<Janus.BaseEntitys.ModuleDTO>
@using Janus.BaseEntitys
    @{
        Layout = null;
        int i = 1;
        ViewBag.ViewTitle = "模块管理";
        List<ModuleDTO> modulesAndRoles = null;
    }
    <form id="pagerForm" method="get" action="System/Module/index?action=page&OpID=@ViewData["OperateID"]">
        <input type="hidden" name="pageNum" value="1" />
        <input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
        <input type="hidden" name="RowCount" value="@ViewData["RowCount"]" />
        @*<input type="hidden" name="orderField" value="${param.orderField}" />
            <input type="hidden" name="Title" value="@SearchParma.Ttile" />
            <input type="hidden" name="IntObj1" value="@SearchParma.IntObj1" />*@
    </form>
    <style>
        .tbleFirstcat {
            background-color: #999;
            font-weight: bold;
            color: #fff;
        }

            .tbleFirstcat:hover {
                color: #000;
            }

        .tbleSecondcat {
            background-color: #ccc;
            font-weight: bold;
            color: #fff;
        }

            .tbleSecondcat:hover {
                color: #000;                
            }
    </style>
    <div class="pageContent">
        @Html.Partial("Buttons", ViewData["CurrentPageButtons"])
        <table class="treetable list" ajax="system\ddd" width="100%" layouth="30">
            <thead>
                <tr>
                    <th>
                        ID
                    </th>
                    <th>
                        名称
                    </th>
                    <th>
                        URL
                    </th>
                    <th>
                        排序
                    </th>
                    <th>
                        父ID
                    </th>
                    <th>
                        类型
                    </th>
                    <th>
                        参数格式
                    </th>
                    <th>
                        点击事件
                    </th>
                    <th>
                        打开方式
                    </th>
                    <th>
                        是否外部
                    </th>
                    <th>
                        允许刷新
                    </th>
                    <th>
                        CssClass
                    </th>
                    <th>
                        备注
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var subitem in Model)
            {
                    <tr data-tt-id="@subitem.ID" data-tt-parent-id="@subitem.Parent">
                        @*<td style="width:30px">@i</td>*@
                        <td>
                            @subitem.ID
                        </td>
                        <td title="@subitem.Title">
                            @subitem.ModuleName
                        </td>
                        <td>
                            @subitem.Url
                        </td>
                        <td>
                            @subitem.Order
                        </td>
                        <td>
                            @subitem.Parent
                        </td>
                        <td>
                            @((GlobaEnum.ModuleTypes)subitem.Types)
                        </td>
                        <td>
                            @subitem.ParmFormat
                        </td>
                        <td>
                            @subitem.OnCilck
                        </td>
                        <td>
                            @subitem.Target
                        </td>
                        <td>
                            @subitem.External
                        </td>
                        <td>
                            @subitem.Fresh
                        </td>
                        <td>
                            @subitem.CssClass
                        </td>
                        <td>
                            @subitem.Remark
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
    @helper GenerateHtml(List<ModuleDTO> models)
    {
int i = 1;
    <table class="list nowrap" width="100%" style="margin-left:5px">
        @foreach (var subitem in models)
        {
            bool hassubcat = false;
            var submodels = Model.Where(c => c.Parent == subitem.ID).OrderBy(c => c.Order).ToList();
            hassubcat = submodels.Count > 0;
            <tr style="@(hassubcat ? "background-color:#ccc" : null)">
                <td style="width:30px">@i</td>
                <td style="width:100px">
                    @subitem.ID
                </td>
                <td style="width:120px" title="@subitem.Title">
                    @subitem.ModuleName
                </td>
                <td style="width:250px">
                    @subitem.Url
                </td>
                <td style="width:30px">
                    @subitem.Order
                </td>
                <td style="width:100px">
                    @subitem.Parent
                </td>
                <td style="width:80px">
                    @((GlobaEnum.ModuleTypes)subitem.Types)
                </td>
                <td style="width:80px">
                    @subitem.ParmFormat
                </td>
                <td style="width:80px">
                    @subitem.OnCilck
                </td>
                <td style="width:80px">
                    @subitem.Target
                </td>
                <td style="width:80px">
                    @subitem.External
                </td>
                <td style="width:80px">
                    @subitem.Fresh
                </td>
                <td style="width:80px">
                    @subitem.CssClass
                </td>
                <td style="width:100px">
                    @subitem.Remark
                </td>
            </tr>
            if (hassubcat)
            {
                <tr>
                    <td colspan="14">
                        @GenerateHtml(submodels)
                    </td>
                </tr>
            }
            i += 1;
        }
    </table>

}
